/**
 * @fileoverview GDrive gui for Coding in Chrome editor.
 *
 * @license Copyright 2016 The Coding with Chrome Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author efuquen@google.com (Edwin Fuquen)
 */

{namespace cwc.soy.GCloud autoescape="strict"}


/**
 * Google Cloud template.
 */
{template .gCloudTemplate}
  {@param prefix: string}
  {@param projects: ?}

  <div id="{$prefix}projects-container">
    <label for="{$prefix}projects">{msg desc=""}Project Id:{/msg}</label>
    <select id="{$prefix}projects">
      <option selected disabled>{msg desc=""}Choose a project{/msg}</option>
      {foreach $project in $projects}
        <option value="{$project['projectId']}">{$project['projectId']}</option>
      {/foreach}
    </select>
  </div>
  <div id="{$prefix}buckets-container"></div>
  <div id="{$prefix}folders-container"></div>
  <div id="{$prefix}public-url"></div>
{/template}


/**
 * Google Cloud Folder list template.
 */
{template .gCloudFolders}
  {@param prefix: string}
  {@param currentFolders: list<?>}
  {@param nextFolders: list<?>}

  <label>
    Folder:
    <span id="{$prefix}folders-nav">
      <button id="{$prefix}folders-path-root">/</button>
      {foreach $folder in $currentFolders}
        <button id="{$prefix}folders-path-{index($folder)}">{$folder}</button>
        <span>/</span>
      {/foreach}
    </span>
    {if length($nextFolders) > 0}
    <select id="{$prefix}folders-picker"/>
      <option selected disabled>Choose folder</option>
      {foreach $folder in $nextFolders}
        <option value="{$folder}">{$folder}</option>
      {/foreach}
    </select>
    {/if}
  </label>
{/template}


/**
 * Google Cloud Bucket list template.
 */
{template .gCloudBuckets}
  {@param prefix: string}
  {@param items: list<?>}

  <label>Bucket Id:
    <select id="{$prefix}buckets">
      {foreach $item in $items}
        <option value="{$item['id']}">{$item['id']}</option>
      {/foreach}
    </select>
  </label>
{/template}


/**
 * Google Cloud Public URL link template.
 */
{template .gCloudPublicURL}
  {@param prefix: string}
  {@param path: string}
  {@param encodedPath: string}

  <label>Public URL:
    <a id="{$prefix}public-url-link" target="_newtab" href="https://storage.googleapis.com/{$encodedPath}">
      https://storage.googleapis.com/{$path}
    </a>
  </labe>
{/template}
